package rc.work.module.infra.dal.mysql.onlyoffice;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import rc.work.framework.common.pojo.PageResult;
import rc.work.framework.mybatis.core.mapper.BaseMapperX;
import rc.work.framework.mybatis.core.query.LambdaQueryWrapperX;
import rc.work.module.infra.controller.admin.onlyoffice.officehistory.vo.OfficeHistoryPageReqVO;
import rc.work.module.infra.dal.dataobject.officehistory.OfficeHistoryDO;


/**
 * onlyoffice历史记录 Mapper
 *
 * @author 默认
 */
@Mapper
public interface OfficeHistoryMapper extends BaseMapperX<OfficeHistoryDO> {

    default PageResult<OfficeHistoryDO> selectPage(OfficeHistoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OfficeHistoryDO>()
                .eqIfPresent(OfficeHistoryDO::getUserId, reqVO.getUserId())
                .eqIfPresent(OfficeHistoryDO::getServerVersion, reqVO.getServerVersion())
                .eqIfPresent(OfficeHistoryDO::getDocKey, reqVO.getDocKey())
                .eqIfPresent(OfficeHistoryDO::getFileUrl, reqVO.getFileUrl())
                .eqIfPresent(OfficeHistoryDO::getFilePath, reqVO.getFilePath())
                .likeIfPresent(OfficeHistoryDO::getFileName, reqVO.getFileName())
                .eqIfPresent(OfficeHistoryDO::getTableName, reqVO.getTableName())
                .eqIfPresent(OfficeHistoryDO::getFileId, reqVO.getFileId())
                .betweenIfPresent(OfficeHistoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OfficeHistoryDO::getId));
    }

    int selectCountByFileId(@Param("fileId") String fileId);
}